package interfaces.hud.pilot;

import java.util.Collection;

import org.fenggui.binding.render.ImageFont;
import org.fenggui.util.Color;

import fileHandling.language.LanguageLoader;

import logic.common.player.awards.Award;
import interfaces.GUISource;
import interfaces.ImageUpdater;
import interfaces.WordWrapHelper;
import interfaces.superWidgets.InterfaceLabel;
import interfaces.superWidgets.StaticContent;

public class AwardView extends StaticContent {
	
	private Collection<InterfaceLabel> labels;
	
	public AwardView(int width, int height, Award award) {
		super(width, height, 0, 0);
		
		ImageFont font = GUISource.middleFont;
		
		String text = LanguageLoader.get(award.getAwardType());
		String labelText = text + " (" + award.getRewardMoney() + ")";
		InterfaceLabel label = new InterfaceLabel(font);
		label.setSize(width, height);
		
		labels = WordWrapHelper.getCentricLabels(label, labelText);
		for(InterfaceLabel l : labels) {
			addWidget(l);
		}
		
		int labelHeight = font.getHeight() * labels.size();
		int imageSize = height - labelHeight;
		int imageX = labelHeight / 2;
		String imageFile = "data/textures/gui/awards/" + award.getAwardType().toString() + ".png";
		ImageUpdater awardImage = new ImageUpdater(imageFile, imageX, labelHeight, imageSize, imageSize);
		addWidget(awardImage);
		
		layout();
	}
	
	public void changeTextColor(Color color) {
		for(InterfaceLabel label : labels) {
			GUISource.setTextColor(label, color);
		}
	}
}